#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;

int a[N];
unordered_map<int, int> h;

int main()
{
	int T; cin >> T;
	while(T --)
	{
		h.clear();
		int n; cin >> n;
		for(int i = 1;i <= n;i ++) cin >> a[i];
		int l = 1, r = 1, ans = 0;
		while(r <= n)
		{
			h[a[r]] ++;
			while(h[a[r]] > 1)  -- h[a[l ++]];
			ans = max(ans, r - l + 1);
			r ++;
		}
		cout << ans << endl;
	}
	return 0;
}